package java结构型设计模式.装饰模式;

public class Main {
    public static void main(String[] args) {
        Printer plasticPrinter = new PlasticPrinter();
        Printer plasticPrinter3D = new Printer3D(new PlasticPrinter());
        Printer  paperPrinter3D = new Printer3D(new PaperPrinter());

        plasticPrinter.print();
        paperPrinter3D.print();
        paperPrinter3D.print();
    }
}
interface Printer{
    void print();
}
class PaperPrinter implements Printer{
    @Override
    public void print() {
        System.out.println("Paper printer");
    }
}
class PlasticPrinter implements Printer{
    @Override
    public void print() {
        System.out.println("Plastic Printer");
    }
}
abstract class PrinterDecorator implements Printer{
    protected  Printer decoratedPrinter;
    public PrinterDecorator(Printer d){
        this.decoratedPrinter = d;
    }
    public void print(){
        decoratedPrinter.print();
    }
}
class Printer3D extends PrinterDecorator{
    public Printer3D(Printer decoratedShape){
        super(decoratedShape);
    }

    @Override
    public void print() {
        System.out.println("3D");
        decoratedPrinter.print();
    }
}


